﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage_List.master" AutoEventWireup="true" CodeFile="PhoneList.aspx.cs" Inherits="Phone_PhoneList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
    <%--fancybox--%>
    <link href="/Resources/js/fancyBox/source/jquery.fancybox.css" rel="stylesheet" />
    <script src="/Resources/js/fancyBox/source/jquery.fancybox.js"></script>
    <link href="/Resources/js/fancyBox/source/helpers/jquery.fancybox-thumbs.css" rel="stylesheet" />
    <script src="/Resources/js/fancyBox/source/helpers/jquery.fancybox-thumbs.js"></script>

    <script src="/Resources/js/json2.js"></script>

    <style type="text/css">
        .div-specification {
            width: 200px;
            height: 90px;
            overflow: hidden;
        }

        .td-select {
            width: 14px;
            text-align: center;
        }

        #grid a {
            color: #0000ff;
            text-decoration: none;
        }

            #grid a:hover {
                text-decoration: underline;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Title" runat="Server">
    产品资料管理
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Search" runat="Server">
    <div id="divSearchBox">
        <table>
            <tr>
                <th>产品类型：</th>
                <td colspan="6">
                    <asp:CheckBoxList ID="cbl_PhoneType" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="ht-checkboxlist"></asp:CheckBoxList>
                </td>
            </tr>
            <tr>
                <th>价格(人民币)：</th>
                <td>
                    <input type="text" id="txt_RMB1" class="ht-textbox text-number" style="width: 54px" />
                    <span>-</span>
                    <input type="text" id="txt_RMB2" class="ht-textbox text-number" style="width: 54px" />

                </td>
                <th>Unit Price(USD)：</th>
                <td>
                    <input type="text" id="txt_USD1" class="ht-textbox text-number" style="width: 54px" />
                    <span>-</span>
                    <input type="text" id="txt_USD2" class="ht-textbox text-number" style="width: 54px" />

                </td>
                <th>MOQ(PCS)：</th>
                <td>
                    <input type="text" id="txt_PCS1" class="ht-textbox text-number" style="width: 54px" />
                    <span>-</span>
                    <input type="text" id="txt_PCS2" class="ht-textbox text-number" style="width: 54px" />

                </td>
                <td></td>
            </tr>
            <tr>
                <th>产品屏幕尺寸：</th>
                <td>
                    <asp:DropDownList ID="ddl_Screen" runat="server" CssClass="ht-select" data-options="editable:false"></asp:DropDownList>
                </td>
                <th>产品芯片类型：</th>
                <td>
                    <asp:DropDownList ID="ddl_Chip" runat="server" CssClass="ht-select" data-options="editable:false"></asp:DropDownList>
                </td>
                <th>产品系列归类：</th>
                <td>
                    <asp:DropDownList ID="ddl_Series" runat="server" CssClass="ht-select" data-options="editable:false"></asp:DropDownList>
                </td>
                <td></td>
            </tr>
            <tr>
                <th>供应商名称：</th>
                <td>
                    <asp:DropDownList ID="ddl_SupplierId" runat="server" CssClass="ht-select"></asp:DropDownList>
                </td>
                <th>供应商型号：</th>
                <td>
                    <input type="text" id="txt_PhoneCode" class="ht-textbox" />
                </td>
                <th>PART NO.：</th>
                <td>
                    <input type="text" id="txt_PartNo" class="ht-textbox" />
                </td>
                <td>
                    <a href="javascript:void(0)" onclick="refreshGrid()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
                    <%--<asp:LinkButton ID="btn_Add" runat="server" Text="增加" PostBackUrl="PhoneEdit.aspx?Action=Add" CssClass="easyui-linkbutton" data-options="iconCls:'icon-add'" />--%>
                    <asp:LinkButton ID="btn_Report" runat="server" Text="导出Excel" CssClass="easyui-linkbutton" data-options="iconCls:'icon-print'" OnClick="btn_Report_Click" OnClientClick="return beforeReportExcel()" />
                    <asp:HiddenField ID="hf_PagerSelected" runat="server" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Content" runat="Server">

    <div class="ht-panel-grid">
        <input type="hidden" id="hf_grid_order" />
        <table id="grid" class="ht-grid" border="0" style="margin-top: 10px;">
            <thead>
                <tr>
                    <th>
                        <input type="checkbox" id="cb_SelectedAll" />
                    </th>
                    <th class="th-order" data-field="AllPhoneTypeName">产品类型
                    </th>
                    <th class="th-order" data-field="SupplierName">供应商资料
                    </th>
                    <th class="th-order" data-field="PhoneCode">供应商型号
                    </th>
                    <th class="th-order" data-field="RMB">价格(人民币)
                    </th>
                    <th class="th-order" data-field="PartNo">PART NO.
                    </th>
                    <th class="th-order" data-field="ScreenName">产品屏幕尺寸
                    </th>
                    <th class="th-order" data-field="ChipName">产品芯片类型
                    </th>
                    <th class="th-order" data-field="SeriesName">产品系列归类
                    </th>
                    <th style="width: 110px">Product Picture</th>
                    <th>Sale Point.</th>
                    <th class="th-order" data-field="USD">Unit Price(USD)
                    </th>
                    <th class="th-order" data-field="PCS">MOQ(PCS)
                    </th>
                    <th style="width: 100px;">操作</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>

    </div>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Pager" runat="Server">
    <div id="pager"></div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Footer" runat="Server">

    <script type="text/javascript">

        $(function () {
            refreshGrid();
        });

        function refreshGrid() {

            var searchParams = searchParams = new Object();
            searchParams.RMB1 = $('#txt_RMB1').val();
            searchParams.RMB2 = $('#txt_RMB2').val();
            searchParams.USD1 = $('#txt_USD1').val();
            searchParams.USD2 = $('#txt_USD2').val();
            searchParams.PCS1 = $('#txt_PCS1').val();
            searchParams.PCS2 = $('#txt_PCS2').val();

            searchParams.Screen = $('#<%=ddl_Screen.ClientID %>').val();
            searchParams.Chip = $('#<%=ddl_Chip.ClientID %>').val();
            searchParams.Series = $('#<%=ddl_Series.ClientID %>').val();

            searchParams.SupplierId = $('#<%=ddl_SupplierId.ClientID%>').val();
            searchParams.PhoneCode = $('#txt_PhoneCode').val();
            searchParams.PartNo = $('#txt_PartNo').val();

            searchParams.PhoneTypes = "";

            $('#<%=cbl_PhoneType.ClientID%> input:checked').each(function () {
                var _id = $(this).parent().attr('data-id');
                if (searchParams.PhoneTypes != '') {
                    searchParams.PhoneTypes += ",";
                }
                searchParams.PhoneTypes += _id;
            });

            $('#<%=hf_PagerSelected.ClientID%>').val('');

            $('#grid').BangleGrid({
                pageSize: 10,
                pager: '#pager',
                url: "PhoneList.aspx/GetGridDataHtml",
                query: searchParams
            });
        }

        //按回车 搜索
        $(function () {
            $('#divSearchBox input,#divSearchBox select,.textbox-text').keypress(function (e) {
                var key = e.which;
                if (key == 13) {
                    refreshGrid();
                }
            });
        });
    </script>

    <script type="text/javascript">
        //展出
        //全选
        $(function () {
            $('#cb_SelectedAll').click(function () {
                try {
                    if ($(this).is(':checked')) {
                        $('.td-select input').attr("CHECKED", "CHECKED");
                    } else {
                        $('.td-select input').removeAttr('CHECKED');
                    }
                }
                catch (e) {
                    alert(e);
                }
            });
        });
        function beforeReportExcel() {
            savePagerSelectedKey();
        }

        function checkedPagerSelected() {
            var _sSelectedString = $('#<%=hf_PagerSelected.ClientID%>').val();

            $('.td-select input').each(function () {
                var _key = ",'" + $(this).val() + "'";
                if (_sSelectedString.indexOf(_key) >= 0) {
                    $(this).attr('CHECKED', 'CHECKED');
                }
            });
        }

        function savePagerSelectedKey() {
            var _sSelectedString = $('#<%=hf_PagerSelected.ClientID%>').val();
            $('.td-select input').each(function () {
                var _key = ",'" + $(this).val() + "'";
                _sSelectedString = _sSelectedString.replace(_key, "");
                if ($(this).is(':checked')) {
                    _sSelectedString += _key;
                }
            });

            $('#<%=hf_PagerSelected.ClientID%>').val(_sSelectedString);
        }
    </script>

    <%--图片展示--%>
    <script>
        function showPicture(id) {
            //$.fancybox.open(src);

            $.ajax({
                type: "post",
                datatype: "json",
                contentType: "application/json",
                url: "PhoneList.aspx/GetPictures",
                data: JSON.stringify({ Id: id }),
                success: function (result) {
                    var dJson = result.d;
                    $.fancybox.open(dJson, {
                        helpers: {
                            thumbs: {
                                width: 50,
                                height: 50
                            }
                        }
                    });
                }
            });

        }
    </script>

    <%--价格输入--%>
    <script>
        $(function () {
            $('.text-number').blur(function () {
                var _num = parseFloat($(this).val()).toFixed(2);
                _num = (_num == 'NaN') ? '' : _num;
                $(this).val(_num);
            });
        });
    </script>



</asp:Content>

